package com.minke.ch11springbootinterceptor.config;

import com.minke.ch11springbootinterceptor.interceptor.UserIntercpetor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 定义此类为配置类
 * @author 何杨谊
 * @description: TODO
 * @date 2022/4/3 22:40
 */
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        String[] addPathPatterns={
                "/api/user/**"
        };
        String[] excludePathPatterns={
                "/api/*/open/**"
        };

        registry.addInterceptor(new UserIntercpetor())
                .addPathPatterns(addPathPatterns)
                .excludePathPatterns(excludePathPatterns);

        WebMvcConfigurer.super.addInterceptors(registry);
    }
}
